package com.test.jdk.streamApi;

import java.util.Optional;
import java.util.stream.Stream;

public class StreamTestFind {
    public static void main(String[] args) {


        //需要找到某些数据，可以使用find方法来实现
        //Optional<T> findFirst();
        //Optional<T> findAny();
        Optional<String> first = Stream.of("1", "3", "3", "4", "5", "1", "7").findFirst();
        System.out.println(first.get());
        // 返回Optional 操作流
        for (int i = 0; i < 7; i++) {
            Optional<String> stringOptional = Stream.of("0", "3", "3", "4", "5", "1", "7").findAny();
            System.out.println( stringOptional.get());
        }



    }
}
